package com.hualan.zhsq.service.impl.information;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hualan.zhsq.entity.information.HouseRental;
import com.hualan.zhsq.mapper.information.HouseRentalMapper;
import com.hualan.zhsq.service.information.HouseRentalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class HouseRentalServiceImpl implements HouseRentalService {

    @Autowired
    private HouseRentalMapper houseRentalMapper;
    @Override
    public int add(HouseRental entity) {
        return 0;
    }

    @Override
    public int edit(HouseRental entity) {
        return 0;
    }

    @Override
    public int remove(Integer id) {
        return 0;
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return 0;
    }

    @Override
    public List<HouseRental> find() {
        Page<HouseRental> houseRentalPage = houseRentalMapper.select(null, null);

        return houseRentalPage.getRecords();
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, HouseRental houseRental) {
        Page<HouseRental> page =new Page<>(pageNum,pageSize);
        Page<HouseRental> houseRentalPage = houseRentalMapper.select(page, houseRental);
        long pages = houseRentalPage.getPages();
        long total = houseRentalPage.getTotal();
        List<HouseRental> houseRentals = houseRentalPage.getRecords();

        Map<String,Object> map = new HashMap<>();
        map.put("total",total);
        map.put("pages",pages);
        map.put("list",houseRentals);
        return map;
    }

    @Override
    public HouseRental findById(Integer id) {
        return null;
    }
}
